package com.xyzwps.paimon.furina.modules.auth.entity

import kotlinx.datetime.LocalDateTime
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.Table
import org.jetbrains.exposed.sql.kotlin.datetime.datetime

class UserPassword(
    val userId: Long,
    val encryptedPassword: String,
    val createTime: LocalDateTime,
    val updateTime: LocalDateTime
) {

    constructor(row: ResultRow) : this(
        userId = row[TABLE.userId],
        encryptedPassword = row[TABLE.encryptedPassword],
        createTime = row[TABLE.createTime],
        updateTime = row[TABLE.updateTime]
    )

    companion object {
        object TABLE : Table("user_password") {
            val userId: Column<Long> = long("user_id")
            val encryptedPassword: Column<String> = varchar("encrypted_password", 300)
            val createTime: Column<LocalDateTime> = datetime("create_time")
            val updateTime: Column<LocalDateTime> = datetime("update_time")

            override val primaryKey = PrimaryKey(userId)
        }
    }
}